package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.ShareCategoryDictMapper;
import com.ghck.server.model.ShareCategoryDict;
import com.ghck.server.model.query.ShareCategoryDictQuery;
import com.ghck.server.service.ShareCategoryDictService;

/**
 * 分享类型  <br>
 * dict_share_category <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class ShareCategoryDictServiceImpl implements ShareCategoryDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(ShareCategoryDictServiceImpl.class);
	
	@Autowired
	private ShareCategoryDictMapper shareCategoryDictMapper;
	
	/**
 	*根据ID删除 分享类型
 	*/
 	@Override
 	public Integer deleteShareCategoryDictById(Integer id){
 		return shareCategoryDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 分享类型
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertShareCategoryDict(List<? extends ShareCategoryDict> shareCategoryDicts){
		Integer count = shareCategoryDictMapper.batchInsert(shareCategoryDicts);
		return count;
 	}
 	/**
 	*新增 分享类型
 	*/
 	@Override
 	@Transactional
 	public Integer insertShareCategoryDict(ShareCategoryDict domain){
		Integer id = shareCategoryDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 分享类型
 	*/
 	@Override
 	@Transactional
 	public Integer updateShareCategoryDict(ShareCategoryDict domain){
		Integer count = shareCategoryDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 分享类型
 	*/
 	public ShareCategoryDict findShareCategoryDictById(Integer id){
 		ShareCategoryDict result = shareCategoryDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 分享类型
 	*/
	public List<ShareCategoryDict> findShareCategoryDictByQuery(ShareCategoryDictQuery query){
		query.dealWith();
		List<ShareCategoryDict> result = shareCategoryDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (ShareCategoryDict shareCategoryDict : result) {
				shareCategoryDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countShareCategoryDictByQuery(ShareCategoryDictQuery query){
 		query.dealWith();
 		Integer result = shareCategoryDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<ShareCategoryDict> findShareCategoryDictByIds(List<Integer> ids){
 		List<ShareCategoryDict> result = shareCategoryDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (ShareCategoryDict shareCategoryDict : result) {
				shareCategoryDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public ShareCategoryDict findByName(String name){
		ShareCategoryDict result = shareCategoryDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<ShareCategoryDict> findAll(){
		List<ShareCategoryDict> result = shareCategoryDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (ShareCategoryDict shareCategoryDict : result) {
				shareCategoryDict.dealWith();
			}
		}
		return result;
	}
}	